#ifndef __SKELETONBONE_H__
#define __SKELETONBONE_H__

#include <export.h>
#include <iobject.h>
#include <gfx/enum.h>
#include <math/matrix.h>
#include <string>
#include <vector>

/**
 * \addtogroup scene
 * @{
 */
/**
 * @brief A single limb within a complex forward kinematic based skeleton
 */
class CE_API ceSkeletonBone : public iObject
{
  friend class ceSkeleton;
  CE_OBJECT
private:

	unsigned										_idx;
  ceAxis                      _axis;
  float                       _length;
  ceVector3f                   _dir;
  ceMatrix4f                   _orientation;
  ceMatrix4f                   _matrix;

  ceSkeletonBone*             _parent;
	std::vector<ceSkeletonBone*>  _children;

	std::string									_name;

  void UpdateDir ();

public:
  ceSkeletonBone(ceAxis axis = A_Z, float length = 1.0f);

	void SetName (const std::string& name);
	const std::string& GetName () const;

  void AddBone (ceSkeletonBone* bone);
  bool RemoveBone (ceSkeletonBone* bone, bool recursive = true);

  ceSkeletonBone* GetParentBone ();
  const ceSkeletonBone* GetParentBone () const;

  void SetAxis (ceAxis axis);
  ceAxis GetAxis () const;

  void SetLength (float length);
  float GetLength () const;

  void SetOrientation (const ceMatrix4f& orientation);
  const ceMatrix4f& GetOrientation () const;

  const ceMatrix4f& GetMatrix () const;

  virtual void UpdateBoneTransformation (const ceMatrix4f& base, ceMatrix4f* destMatrics);

};

/**
 * @}
 */

#endif // SKELETONBONE_H
